<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/12
 * Time: 10:47
 */

//------------------------
//考勤
//-------------------------

namespace app\attendance\controller;
use app\attendance\Base;
use com\gdl\kq\dataobject\platformsetting\platformsettingDTO;
use com\gdl\kq\interfaces\PlatformSettingServiceClient;
use think\Config;
use think\Db;
use think\Exception;
use think\Loader;
date_default_timezone_set("PRC");
class PlatformSettingApi extends Base
{
    /**
     * 获取平台配置
     * @return string
     */
    public function getPlatformSetting()
    {
        $platformId = $this->request->param('platformId') ? $this->request->param('platformId') : 0;
        $adminReg = $this->request->param('adminReg') ? $this->request->param('adminReg') : 0;
        $adminUserId = $this->request->param('adminUserId') ? $this->request->param('adminUserId') : 0;
        $id = $this->request->param('id') ? $this->request->param('id') : 0;
        $key = $this->request->param('key') ? $this->request->param('key') : '';
        if (empty($platformId) || empty($adminReg) ){
            $data = ['msg'=>'参数错误','code'=>400,'data'=>[]];
            return json_encode($data);
        }
        try {
            \ApiClient::init(Config::get('api.appid'), Config::get('api.secret'), 30, array('gdlApiSdk','gdlCloudSdk'));
            $api = new PlatformSettingServiceClient(NULL);
            \ApiClient::build($api);
            $platformsettingDTO = new platformsettingDTO();
            $platformsettingDTO->id	= $id;
            $platformsettingDTO->key	= $key;
            $platformsettingDTO->platformId	= $platformId;
            $platformsettingDTO->data	= [
                'adminUserId'=>$adminUserId,
                'adminReg'=>$adminReg
            ];
            $result = $api->getPlatformSetting($platformsettingDTO);
            $pdata = [];
            if($result->code){
                $pdata = $result->data;
            }
            $data =  ['msg'=>$result->message,'code'=>200,'data'=>$pdata,'count'=>0];
        } catch (Exception $ex) {
            $data = ['msg'=>'失败','code'=>400,'data'=>[],'count'=>0];
        }
        return json_encode($data);

    }
}